

{% for key, element in db_users %}
    {% for err_index, user in element['error']['object'] %}
        obj = $('#load_icon_wait_user[order="{{ key }}"][user="{{ user.getLogin() }}"][base="{{ db_string[user.getBaseId()] }}"]');
        item = $('#user_item[order="{{ key }}"][user="{{ user.getLogin() }}"][base="{{ db_string[user.getBaseId()] }}"]');
        obj.html("{{ element['error']['reason'][err_index] }}");
        obj.append("<br><a href='' id='repeate' obj='db_user' action='{{ element['error']['action'][err_index] }}'>повторить</a>");
        {% if (user.getForRemove() == '0') %}
            obj.append("<br><a href='' id='change' obj='db_user' action='{{ element['error']['action'][err_index] }}'>изменить</a>");
        {% endif %}
        obj.append("<br><a href='' id='hide' obj='db_user' action='{{ element['error']['action'][err_index] }}'>скрыть</a>");
        obj.prepend(error_logo);
        obj.show();
    {% endfor %}
    {% for user in element['ok'] %}
        {% if user.getForRemove() %}
            $('#user_item[order="{{ key }}"][user="{{ user.getLogin() }}"][base="{{ db_string[user.getBaseId()] }}"]').remove();
        {% else %}
            //$('#load_icon_wait_user[order="{{ key }}"][user="{{ user.getLogin() }}"][base="{{ db_string[user.getBaseId()] }}"]').hide();
            $.ajax(
            {
                 type: 'POST',
                 data: {order:"{{ key }}", base:"{{ db_string[user.getBaseId()] }}", user:"{{ user.getLogin() }}"},
                 url: "./shared_dbusers/active",
                 cache: false,
                 success: function(html)
                 {
                    $('#user_item[order="{{ key }}"][base="{{ db_string[user.getBaseId()] }}"][user="{{ user.getLogin() }}"]').replaceWith(html);
                    restore_change_mysql_user_validation("{{ key }}", "{{ db_string[user.getBaseId()] }}", "{{ user.getLogin() }}");
                 }
            });
        {% endif %}
    {% endfor %}
{% endfor %}

{% for key, element in databases %}
    {% for err_index, database in element['error']['object'] %}
        obj = $('#load_icon_wait_db[order="{{ key }}"][base="{{ database.getName() }}"]');
        item = $('#base_item[order="{{ key }}"][base="{{ database.getName() }}"]');
        obj.html("{{ element['error']['reason'][err_index] }}");
        obj.append("<br><a href='' id='repeate' obj='database' action='{{ element['error']['action'][err_index] }}'>повторить</a>");
        {% if (database.getForRemove() == '0') %}
            obj.append("<br><a href='' id='change' obj='database' action='{{ element['error']['action'][err_index] }}'>изменить</a>");
        {% endif %}
        obj.append("<br><a href='' id='hide' obj='database' action='{{ element['error']['action'][err_index] }}'>скрыть</a>");
        obj.prepend(error_logo);
        obj.show();
    {% endfor %}
    {% for database in element['ok'] %}
        {% if database.getForRemove() %}
            $('#base_item[order="{{ key }}"][base="{{ database.getName() }}"]').remove();
        {% else %}
            $.ajax(
            {
                 type: 'POST',
                 data: {order:"{{ key }}", base:"{{ database.getName() }}"},
                 url: "./shared_databases/active",
                 cache: false,
                 success: function(html)
                 {
                    $('#base_item[order="{{ key }}"][base="{{ database.getName() }}"]').replaceWith(html);
                    restore_create_mysql_user_validation("{{ key }}", "{{ database.getName() }}");
                 }
            });  
        {% endif %}
    {% endfor %}
{% endfor %}

{% for key, element in emails %}
    {% for err_index, email in element['error']['object'] %}
        obj = $('#load_icon_wait_email[order="{{ key }}"][email="{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}"]');
        item = $('#email_item[order="{{ key }}"][email="{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}"]');
        obj.html("{{ element['error']['reason'][err_index] }}");
        obj.append("<br><a href='' id='repeate' obj='email' action='{{ element['error']['action'][err_index] }}'>повторить</a>");
        {% if (email.getForRemove() == '0') %}
            obj.append("<br><a href='' id='change' obj='email' action='{{ element['error']['action'][err_index] }}'>изменить</a>");
        {% endif %}
        obj.append("<br><a href='' id='hide' obj='email' action='{{ element['error']['action'][err_index] }}'>скрыть</a>");
        obj.prepend(error_logo);
        obj.show();
    {% endfor %}
    {% for email in element['ok'] %}
        {% if email.getForRemove() %}
            //$('#load_icon_drop_email[order="{{ key }}"][email="{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}"]').hide();
            $('#email_item[order="{{ key }}"][email="{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}"]').remove();
        {% else %}
            //$('#load_icon_create_email[order="{{ key }}"][domain="{{ domain_string[email.getDomainId()] }}"][user="{{ email.getUser() }}"]').hide();
            $.ajax(
            {
                 type: 'POST',
                 data: {order:"{{ key }}", email:"{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}"},
                 url: "./shared_email/active",
                 cache: false,
                 success: function(html)
                 {
                    //$('#email_item[order="{{ key }}"][email="{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}"]').remove();
                    $('#email_item[order="{{ key }}"][email="{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}"]').replaceWith(html);
                    restore_email_validation("{{ key }}", "{{ email.getUser() }}@{{ domain_string[email.getDomainId()] }}");
                 }
            });
        {% endif %}
    {% endfor %}
{% endfor %}

{% for key, element in ftps %}
    {% for err_index, ftp in element['error']['object'] %}
        obj = $('#load_icon_wait_ftp[order="{{ key }}"][user="{{ ftp.getUser() }}"]');
        item = $('#ftp_item[order="{{ key }}"][user="{{ ftp.getUser() }}"]');
        obj.html("{{ element['error']['reason'][err_index] }}");
        obj.append("<br><a href='' id='repeate' obj='ftp_user' action='{{ element['error']['action'][err_index] }}'>повторить</a>");
        {% if (ftp.getForRemove() == '0') %}
            obj.append("<br><a href='' id='change' obj='ftp_user' action='{{ element['error']['action'][err_index] }}'>изменить</a>");
        {% endif %}
        obj.append("<br><a href='' id='hide' obj='ftp_user' action='{{ element['error']['action'][err_index] }}'>скрыть</a>");
        obj.prepend(error_logo);
        obj.show();
    {% endfor %}
    {% for ftp in element['ok'] %}
        {% if ftp.getForRemove() %}
            $('#ftp_item[order="{{ key }}"][user="{{ ftp.getUser() }}"]').remove();
        {% else %}
            $.ajax(
            {
                 type: 'POST',
                 data: {order:"{{ key }}", user:"{{ ftp.getUser() }}"},
                 url: "./shared_ftp/active",
                 cache: false,
                 success: function(html)
                 {
                    $('#ftp_item[order="{{ key }}"][user="{{ ftp.getUser() }}"]').replaceWith(html);
                    restore_change_ftp_validation("{{ key }}", "{{ ftp.getUser() }}");
                 }
            });
        {% endif %}
    {% endfor %}
{% endfor %}

{% for key, element in dnss %}
    {% for err_index, dns in element['error']['object'] %}
        var hashs = MD5("{{ dns.getName()}}{{ dns.getType() }}{{ dns.getValue }}{{ domain_string[dns.getDomainId()] }}");
        
        obj = $('#load_icon_wait_dns[order="{{ key }}"][hashs="' + hashs + '"]');
        item = $('#dns_item[order="{{ key }}"][hashs="' + hashs + '"]');
        obj.html("{{ element['error']['reason'][err_index] }}");
        obj.append("<br><a href='' id='repeate' obj='dns' action='{{ element['error']['action'][err_index] }}'>повторить</a>");
        {% if (dns.getForRemove() == '0') %}
            obj.append("<br><a href='' id='change' obj='dns' action='{{ element['error']['action'][err_index] }}'>изменить</a>");
        {% endif %}
        obj.append("<br><a href='' id='hide' obj='dns' action='{{ element['error']['action'][err_index] }}'>скрыть</a>");
        obj.prepend(error_logo);
        obj.show();
    {% endfor %}
    {% for ok_index, dns in element['ok']['object'] %}
        var pars = "{{ element['ok']['action'][ok_index] }}".split(" ");
        var name = pars[3];
        var type = pars[4];
        var value = pars[5];
        var hashs = MD5("{{ dns.getName() }}{{ dns.getType() }}{{ dns.getValue() }}{{ domain_string[dns.getDomainId()] }}");
        var old_hashs = MD5(name + type + value + "{{ domain_string[dns.getDomainId()] }}");

        {% if dns.getForRemove() %}
            $('#dns_item[order="{{ key }}"][hashs="' + hashs + '"]').remove();
        {% else %}
            $.ajax(
            {
                 type: 'POST',
                 data: {order:"{{ key }}", hash:hashs},
                 url: "./shared_dns/active",
                 cache: false,
                 success: function(html)
                 {
                    $('$dns_item[order="{{ key }}"][hashs="' + old_hashs + '"]').remove();
                    $('#dns_list[order="{{ key }}"]').append(html);
                    sort_dns("{{ key }}"); 
                    //restore_change_ftp_validation("{{ key }}", "");
                 }
            });
        {% endif %}
    {% endfor %}
{% endfor %}